<include file="Public:head" />
<link href="__APP__/Application/{$Think.MODULE_NAME}/Public/css/login.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/js/jquery/validate.js"></script>
<script type="text/javascript">
    function setPwd(){
        var pwd = $('#pwd').val();
        var email = $('#email').text();
        var pwd2 = $('#pwd2').val();
        var rand = $('#rand').val();
        $.post("{:U('Pwd/set_post')}",{
            email:email,
            pwd:pwd,
            rand:rand
        },function(data){
            if(data == -1){
                showTip('系统提示','非法操作',0);
            }else{
               showTip('系统提示','密码修改成功',1,1.5,'',"{:U('Login/index')}");
            }
        })
    }

    $(function(){
        $("#form").validate({
            errorPlacement: function(error, element){
                var error_td = element.parent('li');
                error_td.find('label.error').hide();
                error_td.append(error);
            },
            submitHandler:function(form){
                setPwd()
            },
            rules: {
                pwd : {
                    required : true,
                    minlength: 6,
                    maxlength: 20
                },
                pwd2 : {
                    required : true,
                    equalTo  : '#pwd'
                }
            },
            messages: {
               pwd  : {
                    required : '密码不能为空',
                    minlength: '密码长度应在6-20个字符之间',
                    maxlength: '密码长度应在6-20个字符之间'
                },
                pwd2 : {
                    required : '请再次输入您的密码',
                    equalTo  : '两次输入的密码不一致'
                }
            }
        });
        $("#getcode_gg").click(function(){
            $(this).attr("src",'__PUBLIC__/js/group/code_gg.php?' + Math.random());
        });
    });
   
</script>
<div id="wrap">

    <!--end of header-->
    <div id="container" class="clearfix">
        <div class="login shadow">
            <div class="login-title">
                <h3>设置密码</h3>
            </div>
            <form id="form" method="POST" > 
                <ul>
                    <li class="login_mail" style="margin-top:35px">
                        <label>用户邮箱：</label>
                        <label id="email">{$email}</label>
                    </li>
                    <li class="login_mail">
                        <label>登录密码：</label>
                        <input name="pwd" autofocus type="password" id="pwd" />
                    </li>
                    <li class="login_mail">
                        <label>确认密码：</label>
                        <input name="pwd2"  type="password" id="pwd2" />
                    </li>

                                       
                    <li class="login_btn">
                        <input type="submit" id="sendToMail" value="完成"  />
                        
                    </li>
                    <div class="clear"></div>
                </ul><input type="hidden" id="rand" value="{$rand}">
            </form>

        </div>
        <!--end of login-->
    </div>
    <include file="Public:foot" />